package tc.de.krawallmann.twl.widgets;

import de.matthiasmann.twl.AnimationState;
import de.matthiasmann.twl.Label;
import de.matthiasmann.twl.renderer.AnimationState.StateKey;

/**
 * The Class MulticolorLabel.
 * @author KrawallMann
 * @version 1.0
 */
public class MulticolorLabel extends Label {

	/**
	 * The Enum Color.
	 */
	public enum Color {

		/** The BLUE. */
		BLUE,
		/** The CYAN. */
		CYAN,
		/** The GREEN. */
		GREEN,
		/** The ORANGE. */
		ORANGE,
		/** The RED. */
		RED,
		/** The WHITE. */
		WHITE,
		/** The YELLOW. */
		YELLOW
	}

	/** The Constant BLUE. */
	public static final StateKey BLUE = StateKey.get("blue");

	/** The Constant CYAN. */
	public static final StateKey CYAN = StateKey.get("cyan");

	/** The Constant GREEN. */
	public static final StateKey GREEN = StateKey.get("green");

	/** The Constant ORANGE. */
	public static final StateKey ORANGE = StateKey.get("orange");

	/** The Constant RED. */
	public static final StateKey RED = StateKey.get("red");

	/** The Constant WHITE. */
	public static final StateKey WHITE = StateKey.get("white");

	/** The Constant YELLOW. */
	public static final StateKey YELLOW = StateKey.get("yellow");

	private Color color;

	/**
	 * Instantiates a new multicolor label.
	 */
	public MulticolorLabel() {
		super();
		final AnimationState state = getAnimationState();
		state.setAnimationState(MulticolorLabel.RED, false);
		state.setAnimationState(MulticolorLabel.GREEN, false);
		state.setAnimationState(MulticolorLabel.BLUE, false);
		state.setAnimationState(MulticolorLabel.ORANGE, false);
		state.setAnimationState(MulticolorLabel.CYAN, false);
		state.setAnimationState(MulticolorLabel.YELLOW, false);
	}

	/**
	 * Instantiates a new multicolor label.
	 * 
	 * @param text
	 *            the text
	 */
	public MulticolorLabel(final String text) {
		super(text);
		final AnimationState state = getAnimationState();
		state.setAnimationState(MulticolorLabel.RED, false);
		state.setAnimationState(MulticolorLabel.GREEN, false);
		state.setAnimationState(MulticolorLabel.BLUE, false);
		state.setAnimationState(MulticolorLabel.ORANGE, false);
		state.setAnimationState(MulticolorLabel.CYAN, false);
		state.setAnimationState(MulticolorLabel.YELLOW, false);
	}

	public Color getColor() {
		return color;
	}

	/**
	 * Sets the color.
	 * 
	 * @param color
	 *            the new color
	 */
	public void setColor(final Color color) {
		this.color = color;
		final AnimationState state = getAnimationState();
		state.setAnimationState(MulticolorLabel.RED, false);
		state.setAnimationState(MulticolorLabel.GREEN, false);
		state.setAnimationState(MulticolorLabel.BLUE, false);
		state.setAnimationState(MulticolorLabel.ORANGE, false);
		state.setAnimationState(MulticolorLabel.CYAN, false);
		state.setAnimationState(MulticolorLabel.YELLOW, false);
		state.setAnimationState(MulticolorLabel.WHITE, false);
		switch (color) {
			case RED: {
				state.setAnimationState(MulticolorLabel.RED, true);
				break;
			}
			case GREEN: {
				state.setAnimationState(MulticolorLabel.GREEN, true);
				break;
			}
			case BLUE: {
				state.setAnimationState(MulticolorLabel.BLUE, true);
				break;
			}
			case CYAN: {
				state.setAnimationState(MulticolorLabel.CYAN, true);
				break;
			}
			case ORANGE: {
				state.setAnimationState(MulticolorLabel.ORANGE, true);
				break;
			}
			case YELLOW: {
				state.setAnimationState(MulticolorLabel.YELLOW, true);
				break;
			}
			default: {
				state.setAnimationState(MulticolorLabel.WHITE, true);
			}
		}
	}

}
